﻿@model AttachmentType
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Form.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Main
{
    @Html.HiddenFor(model => model.Id)
    <fieldset>
        <legend>基本设置</legend>
        <table>
            <col width="120px" />
            <tr>
                <th>
                    @Html.LabelFor(model => model.Name, "名称")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Name, new ValidateOptions
                    {
                        RequiredError = "请输入名称",
                        LengthMax = 64
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Name)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Key, "代码")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Key, new ValidateOptions
                    {
                        RequiredError = "请输入代码",
                        LengthMax = 64
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Key)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Description, "描述")
                </th>
                <td>
                    @Html.MyNet().TextAreaFor(model => model.Description, new ValidateOptions
                    {
                        LengthError = "不能超过256字符",
                        LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Description)
                </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    @Html.CheckBoxFor(model => model.IsMultiVersion)
                    @Html.LabelFor(model => model.IsMultiVersion, "是否多版本")
                    @Html.CheckBoxFor(model => model.IsMultiVersionFromPackage)
                    @Html.LabelFor(model => model.IsMultiVersionFromPackage, "版本是否来自压缩包")
                    @Html.CheckBoxFor(model => model.IsRemoveFile)
                    @Html.LabelFor(model => model.IsRemoveFile, "删除数据时是否删除文件")
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend>附件路径设置</legend>
        <table>
            <col width="120px" />
            <tr>
                <th>
                    @Html.LabelFor(model => model.DirectoryMode, "目录组织方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.DirectoryMode,
                    new[]
                    {
                        new { Value = (int)DirectoryMode.ByNone, Name = DirectoryMode.ByNone.ToText() },
                        new { Value = (int)DirectoryMode.ByNoneRemainFileName, Name = DirectoryMode.ByNoneRemainFileName.ToText() },
                        new { Value = (int)DirectoryMode.ByDate, Name = DirectoryMode.ByDate.ToText() },
                        new { Value = (int)DirectoryMode.ByDateRemainFileName, Name = DirectoryMode.ByDateRemainFileName.ToText() },
                        new { Value = (int)DirectoryMode.ByAttachmentKey, Name = DirectoryMode.ByAttachmentKey.ToText() },
                        new { Value = (int)DirectoryMode.ByAttachmentKeyRemainFileName, Name = DirectoryMode.ByAttachmentKeyRemainFileName.ToText() }
                    }, "Value", "Name", "请选择目录组织方式",
                    new ValidateOptions
                    {
                        RequiredError = "请选择目录组织方式"
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.DirectoryMode)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.StorageMode, "数据存储方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.StorageMode,
                    new[]
                    {
                        new { Value = (int)StorageMode.Directory, Name = StorageMode.Directory.ToText() },
                        new { Value = (int)StorageMode.DataBase, Name = StorageMode.DataBase.ToText() },
                        //new { Value = (int)StorageMode.Ftp, Name = StorageMode.Ftp.ToText() }
                        
                    }, "Value", "Name", "请选择目录组织方式",
                    new ValidateOptions
                    {
                        RequiredError = "请选择数据存储方式"
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.StorageMode)
                </td>
            </tr>
            @*<tr>
                <th>
                    @Html.LabelFor(model => model.FTPSetting, "FTP设置")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.FTPSetting, new ValidateOptions
                    {
                        LengthMax = 256
                    })
                    (未使用ftp存储可不填)
                </td>
            </tr>*@
            <tr>
                <th>
                    @Html.LabelFor(model => model.AccessMode, "附件访问方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.AccessMode,
                    new[]
                    {
                        new { Value = (int)AccessMode.UnAuthorizationAccess, Name = AccessMode.UnAuthorizationAccess.ToText() },
                        new { Value = (int)AccessMode.AuthorizationAccess, Name = AccessMode.AuthorizationAccess.ToText() }
                    }, "Value", "Name", "请选择附件访问方式",
                    new ValidateOptions
                    {
                        RequiredError = "请选择附件访问方式"
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.AccessMode)
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend>上传验证设置</legend>
        <table>
            <col width="120px" />
            <tr>
                <th>
                    @Html.LabelFor(model => model.FilterFileExtensions, "有效的文件后缀")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.FilterFileExtensions, new ValidateOptions
                    {
                        LengthMax = 256
                    })
                    ("*"表示所有类型后缀;多个后缀用","隔开)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.MaxFileSize, "允许文件最大值")
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.MaxFileSize)
                    KB (0时为不限制文件大小)
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend>上传图片设置</legend>
        <table>
            <col width="120px" />
            <tr>
                <th></th>
                <td>
                    @Html.CheckBoxFor(model => model.IsGenerateThumbnail)
                    @Html.LabelFor(model => model.IsGenerateThumbnail, "是否生成缩略图")
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.ThumbnailMaxFileSize, "文件大于该值时生成缩略图")
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.ThumbnailMaxFileSize)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.ThumbnailSizes, "缩略图规格")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ThumbnailSizes, new ValidateOptions
                    {
                        LengthMax = 256
                    })
                    (宽高用"_"隔开,"*"表示自适应;多种规格用","隔开)
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset>
        <legend>水印设置</legend>
        <table>
            <col width="120px" />
            <tr>
                <th>
                    @Html.LabelFor(model => model.WatermarkMethod, "水印方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.WatermarkMethod, new[]
                    {
                        new { Value = (int)WatermarkMethod.None, Name = WatermarkMethod.None.ToText() },
                        new { Value = (int)WatermarkMethod.Text, Name = WatermarkMethod.Text.ToText() },
                        new { Value = (int)WatermarkMethod.Image, Name = WatermarkMethod.Image.ToText() }
                    }, "Value", "Name")
                    @Html.MyNet().ValidationMessageFor(model => model.WatermarkMethod)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.WatermarkHorizontalAlign, "水印水平对齐方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.WatermarkHorizontalAlign,
                    new[]
                    {
                        new { Value = "NotSet", Name = "未设置" },
                        new { Value = "Left", Name = "居左" },
                        new { Value = "Center", Name = "居中" },
                        new { Value = "Right", Name = "居右" },
                        new { Value = "Justify", Name = "均匀展开" },
                    }, "Value", "Name")
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.WatermarkVerticalAlign, "水印垂直对齐方式")
                </th>
                <td>
                    @Html.MyNet().DropDownListFor(model => model.WatermarkVerticalAlign,
                    new[]
                    {
                        new { Value = "NotSet", Name = "未设置" },
                        new { Value = "Top", Name = "顶部" },
                        new { Value = "Middle", Name = "居中" },
                        new { Value = "底部", Name = "Bottom" },
                    }, "Value", "Name")
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.WatermarkText, "水印文字")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.WatermarkText, new ValidateOptions
                    {
                        LengthMax = 64
                    })
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.WatermarkImageUrl, "水印图片URL")
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.WatermarkImageUrl, new ValidateOptions
                    {
                        LengthMax = 512
                    })
                </td>
            </tr>
        </table>
    </fieldset>
}
<script>

    function save()
    {
        var form = $("form");
        if (!form.valid()) return;

        $.ajax
        ({
            url: form.attr("action"),
            data: form.serialize(),
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                back(true);
            }
        });
    }

</script>
